package com.lagou.rpc.client;

import com.alibaba.druid.pool.DruidDataSource;

import java.util.concurrent.atomic.AtomicReference;

/**
 * 线程安全的dataSource引用
 */
public class ThreadDataSource {
    private static AtomicReference<DruidDataSource> threadLocal = new AtomicReference<>();
    public static void set(DruidDataSource ds) {
        threadLocal.set(ds);
    }
    public static DruidDataSource get() {
        return threadLocal.get();
    }
    public static void remove() {
        threadLocal.set(null);
    }
}
